'use strict'

var initDb=require('./utils/initDb');

 initDb();
//安装了 npm init /npm install crawler

// var articles =require("./module/articles");

var Crawler = require("crawler");
var articles = require('./model/articles')
var c = new Crawler({
    maxConnections : 10,
    // This will be called for each crawled page
    callback : function (error, res, $) {
        // $ is Cheerio by default
        //a lean implementation of core jQuery designed specifically for the server
        if(error){
            console.log(error);
        }else{
            var $ = res.$;

            var list =$('#content .articles table').toArray();

            list.forEach(element =>{
                var title=$(element).text();

                console.log(txt);
            })
            console.log(list);

            console.log($("title").text());

        }
        done();
    }
});
 
// Queue just one URL, with default callback
c.queue('https://book.douban.com/top250?icn=index-book250-all');
